package com.frxuexi.base.utils

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils

class ArouterService:NavigationCallback {
    override fun onFound(postcard: Postcard?) {

    }

    override fun onLost(postcard: Postcard?) {
        ToastUtils.showLong("找不到路径：${postcard?.path}")
        postcard?.context.let {
            ARouter.getInstance().build("/app/NoFoundActivity").navigation()
        }
    }

    override fun onArrival(postcard: Postcard?) {
    }

    override fun onInterrupt(postcard: Postcard?) {
    }
}

object ArouterManager{
    fun navigation(context: Context,path:String,key:String?="",para:String?=""){
        ARouter.getInstance().build(path).withString(key,para).navigation(context,ArouterService())
    }
}